<!-- Header -->
	<header class="header navbar navbar-fixed-top" role="banner">
		<!-- Top Navigation Bar -->
		<div class="container">

			<!-- Only visible on smartphones, menu toggle -->
			<ul class="nav navbar-nav">
				<li class="nav-toggle"><a href="javascript:void(0);" title=""><i class="icon-reorder"></i></a></li>
			</ul>

			<!-- Logo -->
			<a class="navbar-brand" href="index.html">
				<img src="<?php echo Yii::app()->request->baseUrl; ?>/images/logoagra.png" alt="logo" style="height:48px;width:145px;" />
			</a>
			<!-- /logo -->

			<!-- Sidebar Toggler -->
			<!--
			<a href="#" class="toggle-sidebar bs-tooltip" data-placement="bottom" data-original-title="Toggle navigation">
				<i class="icon-reorder"></i>
			</a>
			-->
			<!-- /Sidebar Toggler -->

			<!-- Top Left Menu -->
			<ul class="nav navbar-nav navbar-left hidden-xs hidden-sm">
			<!--	<li>
					<a href="#">
						Dashboard
					</a>
				</li>
-->
			<?php  
				$parents = RoleMenu::model()->findAll('parent_id=0');
				foreach($parents as $parent):
			?>
				<li class="dropdown user">
					<a href="#" class="dropdown-toggle" data-toggle="dropdown">
						<i class="icon-desktop"></i>
							<?php echo $parent->menu_name; ?>
						<i class="icon-caret-down small"></i>
					</a>
					<ul class="dropdown-menu">
					<?php 
						$query = "select m.id, m.parent_id, m.menu_name, m.menu_addreess from role_menu m join role_menu_access a on m.id=a.role_id and a.access_status=1 and a.level = ".Yii::app()->user->getLevel()." where parent_id=".$parent->id;
						$child1 = Yii::app()->db->createCommand($query)->queryAll();
						foreach($child1 as $item1):
						if($item1['menu_addreess'] != '#'){
					?>
						
						<li>
						<a href="<?php echo Yii::app()->createUrl($item1['menu_addreess']); ?>">
								<i class="icon-angle-right"></i>
								<?php echo $item1['menu_name']; ?>
						</a>	
						</li>
						<?php }else{ ?>
						<li>
								<a href="#">
								<i class="icon-angle-right"></i>
								<?php echo $item1['menu_name']; ?>
								</a>
								<ul class="sub-menu">
								<?php 
									$query2 = "select m.id, m.parent_id, m.menu_name, m.menu_addreess from role_menu m join role_menu_access a on m.id=a.role_id and a.access_status=1 and a.level = ".Yii::app()->user->getLevel()." where parent_id=".$item1['id'];
									$child2 = Yii::app()->db->createCommand($query2)->queryAll();
									foreach($child2 as $item2):
									?>
									<li>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<a href="<?php echo Yii::app()->createUrl($item2['menu_addreess']); ?>">
									<i class="icon-angle-right"></i>
									<?php echo $item2['menu_name']; ?>
									</a>
									</li>
									<?php endforeach; ?>
								</ul>
						</li>
						<?php } ?>
						<?php endforeach; ?>

					</ul>
				</li>

			<?php endforeach; ?>

			</ul>
			<!-- /Top Left Menu -->

			<!-- Top Right Menu -->
			<ul class="nav navbar-nav navbar-right">
				<!-- User Login Dropdown -->
				<li class="dropdown user">
					<a href="#" class="dropdown-toggle" data-toggle="dropdown">
						<i class="icon-male"></i>
						<span class="username"><?php echo User::model()->findByPk(Yii::app()->User->Getid())->username; ?></span>
						<i class="icon-caret-down small"></i>
					</a>
					<ul class="dropdown-menu">
						<li><a href="<?php echo Yii::app()->createUrl('/user/logout'); ?>"><i class="icon-key"></i> Keluar</a></li>
					</ul>
				</li>
				<!-- /user login dropdown -->
			</ul>
			<!-- /Top Right Menu -->
		</div>
		<!-- /top navigation bar -->
	</header> <!-- /.header -->